﻿using System.Windows;

namespace CommonUtils.Wpf.Test
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            Loaded += MainWindow_Loaded;
            ButtonTest.Click += ButtonTest_Click;
            TextBoxSource.Load();
            TextBoxSource.SaveOnChange();
        }

        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            ComboBoxAction.Items.Add("JsonClear");
            ComboBoxAction.SelectedIndex = 0;
        }

        private void ButtonTest_Click(object sender, RoutedEventArgs e)
        {
            switch (ComboBoxAction.Text)
            {
                case "JsonClear":
                    var jObject = JsonUtil.ParseToJObject(TextBoxSource.Text);
                    jObject.ClearDeepest("xxxxxxxxxxxxxxxxxxxxxxxx");
                    TextBoxtarget.Text = jObject.ToJson();
                    TextBoxtarget.Text.SetToClipboard();
                    break;
            }
        }
    }
}
